/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package UI;

//import static digitester.GateGlobal.size;
import java.awt.Graphics2D;
import java.awt.Point;

/**
 *
 * @author pwarnimo
 */
public class ToggleSwitch extends GateGlobal {
    public static final String value = "";
    public static final int type = 0;
    public static final int Outputs = 1;
    public static final int Inputs = 1;
    public static final boolean Negated = false;
    
    private boolean toggled = false;
    
    public ToggleSwitch(Point Coords, int ID) {
        super(type, Coords, Outputs, Inputs, Negated, ID);
        this.setGateType(0);
    }
    
    @Override
    public void paintGate(Graphics2D g2) {
        super.paintGate(g2);
        //g2.drawString(value, this.Coords.x + (size / 2), this.Coords.y + (size / 2));
        
        //g2.drawString("M=0", Coords.x + 6, Coords.y + 11);
        
        if (toggled == false) {
            g2.drawLine(this.Coords.x , this.Coords.y + (size / 2), this.Coords.x + (size / 2) - 10, this.Coords.y + (size / 2));
            g2.drawLine(this.Coords.x + (size / 2) - 10, this.Coords.y + (size / 2), this.Coords.x + (size / 2) + 10, this.Coords.y + (size / 2) - 5);
            g2.drawLine(this.Coords.x + (size / 2) + 10 , this.Coords.y + (size / 2), this.Coords.x + size, this.Coords.y + (size / 2));
            g2.drawString("OFF", Coords.x + 6, Coords.y + size - 1);
        }
        else {
            g2.drawLine(this.Coords.x, this.Coords.y + (size / 2), this.Coords.x + size, this.Coords.y + (size / 2));
            g2.drawString("ON", Coords.x + 6, Coords.y + size - 1);
        }
    }
    
    public void toggle() {
        toggled = !toggled;
        System.out.println(toggled);
    }
}
